#include "devsetup.h"
#include <QAudioInput>
#include <QAudioOutput>
#include "mainwindow.h"
#include <QDebug>

//--------------------------------------------------------------------------
// DevSetup constructor and destructor
//--------------------------------------------------------------------------
DevSetup::DevSetup(QWidget *parent) :	QDialog(parent)
{
  ui.setupUi(this);	//setup the dialog form

  QList<QAudioDeviceInfo> InDevices;
  QList<QAudioDeviceInfo> OutDevices;
  QAudioDeviceInfo deviceInfo;

  InDevices = deviceInfo.availableDevices(QAudio::AudioInput);
  OutDevices = deviceInfo.availableDevices(QAudio::AudioOutput);

  foreach (const QAudioDeviceInfo &deviceInfo, InDevices) {
    ui.comboBoxSndIn->addItem(deviceInfo.deviceName(),
                              qVariantFromValue(deviceInfo));
  }
  foreach (const QAudioDeviceInfo &deviceInfo, OutDevices) {
    ui.comboBoxSndOut->addItem(deviceInfo.deviceName(),
                               qVariantFromValue(deviceInfo));
  }

}

DevSetup::~DevSetup()
{
}

void DevSetup::on_networkRadioButton_clicked()
{
  m_requestNetwork = true;
  ui.comboBoxSndIn->setEnabled(!m_requestNetwork);
}

void DevSetup::on_soundCardRadioButton_clicked()
{
  m_requestNetwork = false;
  ui.comboBoxSndIn->setEnabled(!m_requestNetwork);
}

void DevSetup::setNetwork(bool b)
{
  m_requestNetwork = b;
  ui.networkRadioButton->setChecked(b);
  ui.comboBoxSndIn->setEnabled(!m_requestNetwork);
}
